/*
 * Created on Jul 22, 2005
 *
 */
package com.erclab.internal.xpresso.webapp;

/**
 * @author Enrique Rodriguez.
 *
 */
public class HTMLHelper {

	/*
	 * NOT USED ANYMORE. LEFT HERE FOR REFERENCE 
	  public static String getCalendarBox2(String elementName, String elementId, String elementValue, String formName){
		StringBuffer sb = new StringBuffer();
		
		sb.append("<INPUT TYPE=\"text\" name=\"" + elementName + "\" ");
		sb.append("id=\"" + elementId + "\"");
		if (elementValue != null){
			sb.append(" value=\"" + elementValue + "\"");
		}
			
		sb.append(" onClick=\"alertCalendarUsage(this)\">");
		sb.append("&nbsp;<a href=javascript:CalendarDate('" + elementName);
		sb.append("')><img src=../grad/html/images/DateSearch.gif width=19 height=17 border=0></a>");
		sb.append("<table width=1 border=0 align=center cellpadding=0 cellspacing=0><tr><td>");
		sb.append("<div id=\"Calendar" + elementName + "\" style=\"position:absolute; z-index:5; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000;");
		sb.append('"' + "></div>");
		sb.append("</td></tr></table>");		
		
		// Add javascript calendar date
		sb.append("\n<script type=\"text/javascript\">");
		sb.append("\nfunction CalendarDate(idField){\n");
		sb.append("addCalendar(\"Calendar\" + idField, \"Calendar\"+ idField, idField, \"" + formName + "\"" + ");\n");
		sb.append("showCal(\"Calendar\" + idField);\n");
		sb.append("\n}\n</script>");

		return sb.toString();
	}*/

	public static String getCalendarBox(String elementName, String elementId, String elementValue, String formName){
		StringBuffer sb = new StringBuffer();
		
		sb.append("<SCRIPT LANGUAGE=\"JavaScript\" ID=\"jscal"+  elementName + "\">");
		sb.append("var cal" + elementName + " = new CalendarPopup(\"div" +  elementName + "\");");
		sb.append("cal" + elementName + ".showNavigationDropdowns();");
		sb.append("</SCRIPT>");
		sb.append("<INPUT TYPE=\"text\" NAME=\""+  elementName + "\"");
		sb.append(" id=\""+  elementId + "\"");
		if (elementValue != null){
			sb.append(" value=\"" + elementValue + "\"");
		}
		sb.append(" SIZE=12");
		sb.append(" onAfterUpdate=\"formElementChanged(this)\">");
		sb.append("<A HREF=\"#\" onClick=\"cal" + elementName + ".select(document." + formName);
		sb.append("." + elementName + ",'anchor" + elementName + "','MM/dd/yyyy'); return false;\" TITLE=\"cal" + elementName);
		sb.append(".select(document." + formName + ".date1xx,'anchor" + elementName);
		sb.append("','MM/dd/yyyy'); return false;\" NAME=\"anchor" + elementName);
		sb.append("\" ID=\"anchor" + elementName + "\"><img src=\"../xpresso/html/images/DateSearch.gif\" border=0></A>");
		sb.append("<DIV ID=\"div" + elementName + "\" STYLE=\"position:absolute;visibility:hidden;background-color:white;layer-background-color:white;\"></DIV>");
		return sb.toString();
	}

}
